import {request} from '../../utils/http'

Page({
  data: {
    id:'',
    result:'',
  },
  onLoad(query) {
    // let options = my.getEnterOptionsSync();
    // console.log(options, query, '参数')
    // let queryStr = decodeURIComponent(options.query.query)
    // let arg = queryStr.split('&')
    // let queryObj = {}
    // arg.forEach(item => {
    //   let i = item.split('=')
    //   queryObj[i[0]] = i[1]
    // })
    let id = query.order_id;
    // let result = queryObj.result;
    // console.log(id, result, queryStr, arg,'canshu')
    // let id = my.getStorageSync({key:'blockchain_id'}).data
    console.log(id, 'idiodidiidid')
    this.setData({
      id
    },() => {
      this.getDetail()
    })
  },
  getDetail(){
    let id = this.data.id;
    request('/order/' + id, 'get', {queryStatus:1}).then(res => {
      console.log(res)
      if (res.code == 200) {
        let status  = res.data.status;
        let result;
        if (status == 10) {
          result = 3
        } else if (status != 10 && status !=-1) {
          result = 1
        } else if (status == -1) {
          result = 2
        }

         this.setData({
          result
         })
      }
    })
  },
  goOrder(){
    my.navigateTo({ url: '../orderDetail/index?id=' + this.data.id + '&type=1'})
  },
  goPortal(){
    my.switchTab({
      url:'../index/index'
    })
  }
});
